#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <stdlib.h>
#include <stdio.h>

struct sembuf sem[3];
struct shared *segptr;
int shmid;
int semid;
short sarray[3];
int client_sem=0,server_sem=1;
int anyclient=2;	
void sem_signal(int which) {
		sem[0].sem_num = which;
		sem[0].sem_op =  -1; 
	        sem[0].sem_flg = 0;
		semop(semid, sem, 1);
}

void sem_wait(int which) {
	sem[0].sem_num = which;
	sem[0].sem_op =  0; 
	sem[0].sem_flg = 0;
        sem[1].sem_num = which;
	sem[1].sem_op =  1; 
	sem[1].sem_flg = 0;
	semop(semid, sem, 2);
}
